package com.lucian.ge.service.shop.impl;

import com.lucian.ge.dao.shop.CartMapper;
import com.lucian.ge.service.shop.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;
import java.util.List;
import java.util.Map;
import java.util.Random;

/**
 * Created by Lucicol on 2019/7/10.
 */
@Service("OrderServicel")
public class OrderServicelmpl implements OrderService {

    @Autowired(required=false)
    private CartMapper cartMapper;

    public void create(Integer userId,Integer shippingId) {
        List<Map<String, String>> cartList = cartMapper.selectList(userId);
        BigDecimal payment = new BigDecimal("0");
//        for(OrderItem orderItem : orderItemList){
//            payment = BigDecimalUtil.add(payment.doubleValue(),orderItem.getTotalPrice().doubleValue());
//        }
        long orderNo = this.generateOrderNo();
        System.out.println(orderNo);
        System.out.println(cartList);
        System.out.println(payment);
    }

    private long generateOrderNo(){
        long currentTime =System.currentTimeMillis();
        return currentTime+new Random().nextInt(100);
    }
}
